package com.eastjet.maintenance.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.eastjet.maintenance.domain.DeviceType;
import com.eastjet.maintenance.mapper.DeviceTypeMapper;
import com.eastjet.maintenance.service.DeviceTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Objects;

/**
 * @author 杨博文
 * @description 针对表【device_type(设备类型)】的数据库操作Service实现
 * @createDate 2024-11-25 09:23:38
 */
@Service
public class DeviceTypeServiceImpl extends ServiceImpl<DeviceTypeMapper, DeviceType> implements DeviceTypeService {

    @Autowired
    private DeviceTypeMapper deviceTypeMapper;

    @Override
    public Boolean InsertType(DeviceType type) {
        return this.save(type);
    }

    /**
     * 查询设备类型列表
     *
     * @return
     */
    @Override
    public List<DeviceType> findDeviceTypeList() {
        return deviceTypeMapper.selectAllType();
    }

    /**
     * 查询设备类型列表排序
     *
     * @return
     */
    @Override
    public List<DeviceType> findTypeList() {
        return this.list(new QueryWrapper<DeviceType>().eq("tombstone", 0).isNotNull("fu").orderByAsc("xu"));
    }

    /**
     * 修改设备类型
     *
     * @param type
     * @return
     */
    @Override
    public Boolean updateType(List<DeviceType> type) {
        return this.updateBatchById(type);
    }

    /**
     * 修改设备类型状态
     *
     * @param code
     * @param status
     * @return
     */
    @Override
    public Boolean updateQi(@Param("status") String status, @Param("code") String code) {
        return deviceTypeMapper.updateQi(status, code) == 1 ? true : false;
    }

    @Override
    public Boolean DeleteType(String code) {
        return deviceTypeMapper.DeleteType(code) == 1 ? true : false;
    }

    /*
     *搜索设备类型列表查询
     */
    @Override
    public List<DeviceType> findDeviceTypeListByStatus(String name) {
        return this.list(new QueryWrapper<DeviceType>().like("name", name).or().like("encode", name));
    }

}




